import { ajaxService } from '@/utils/request';

const env = import.meta.env;
let baseURL = env.VITE_PRODUCE_URL;

export function getOutsourcingSupplier(params: { id: number }) {
  return ajaxService({
    url: '/produce/outsourcing/supplier',
    method: 'get',
    params,
    baseURL,
  });
}

export function postOutsourcing(data: any) {
  return ajaxService({
    url: '/produce/outsourcing/post',
    method: 'post',
    data,
    baseURL,
  });
}

export function getOutsourcingAll(params: any) {
  return ajaxService({
    url: '/produce/outsourcing/getall',
    method: 'get',
    params,
    baseURL,
  });
}

export function getOutsourcingOne(params: { id: number }) {
  return ajaxService({
    url: '/produce/outsourcing/getone',
    method: 'get',
    params,
    baseURL,
  });
}

export function putOutsourcingOne(data: any) {
  return ajaxService({
    url: '/produce/outsourcing/put',
    method: 'put',
    data,
    baseURL,
  });
}

export function delOutsourcingOne(params: { id: number }) {
  return ajaxService({
    url: '/produce/outsourcing/delete',
    method: 'delete',
    params,
    baseURL,
  });
}

export function confirmOutsourcingOne(data: { id: number }) {
  return ajaxService({
    url: '/produce/outsourcing/confirm',
    method: 'put',
    data,
    baseURL,
  });
}

// 通过工序数组查询上一个工序
export function getProcessGroupProduct(params: number[]) {
  return ajaxService({
    url: '/produce/outsourcing/get/product',
    method: 'get',
    params,
    baseURL,
  });
}

// 通过工序id查询产出物
export function getProcessGroupProductOne(params: { id: number }) {
  return ajaxService({
    url: '/produce/outsourcing/getOne/product',
    method: 'get',
    params,
    baseURL,
  });
}
